package com.objecteffects.ilmp.util;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

import com.objecteffects.ilmp.model.PostsType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Rusty Wright
 */
@Converter
public final class PostsTypeConverter implements
AttributeConverter<PostsType, String> {
    @SuppressWarnings("unused")
    private final transient Logger log = LoggerFactory
        .getLogger(PostsTypeConverter.class);

    @Override
    public String convertToDatabaseColumn(final PostsType attribute) {
        return attribute.toString();
    }

    @Override
    public PostsType convertToEntityAttribute(final String name) {
        return PostsType.fromString(name);
    }
}
